package com.springboot.controller.api;

import com.springboot.biz.ItemBiz;
import com.springboot.biz.PipeBiz;
import com.springboot.entity.Pipe;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController(value = "apiPipeConttoller")
@RequestMapping(value = "/api/pipe")
public class PipeController {

    @Resource
    private PipeBiz pipeBiz;
    @Resource
    private ItemBiz itemBiz;

    @RequestMapping(value = "/findinfo")
    public Pipe findInfo(@RequestParam(defaultValue = "0") int id) {
        Pipe pipe = pipeBiz.findInfoPipe(id, null);
        if (pipe != null)
            pipe.setItems(itemBiz.findListItem(pipe));
        return pipe;
    }

}
